<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var mouth = parseInt(prompt("请输入月份"));
    switch(mouth){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            alert(31);
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            alert(30);
            break;
        case 2:
            var year = parseInt(prompt("请输入年份"));
            if(year % 100 == 0){
                // 无余为闰，有余不闰。
                if(year % 400 == 0){
                    alert(29)
                }else{
                    alert(28)
                }
            }else{
                if(year % 4 == 0){
                    alert(29) 
                }else{
                    alert(28)
                }  
            }
            break;
        default:
            alert("请输入正确月份")
    }
</script>
</html>